#ifndef WII_GI_C_RESOURCE_MGR_H
#define WII_GI_C_RESOURCE_MGR_H

#include <map>
#include <list>
#include "xmlParser.h"
#include "c_Resource.h"
#include "c_Sprite.h"
#include "c_Texture.h"

namespace wiigi
{
   
   class c_ResourceMgr
   {
   public:
      c_ResourceMgr(void);
      c_ResourceMgr( std::string& ScriptName );
      
      virtual ~c_ResourceMgr(void);
      
      bool loadScript( const std::string& ScriptName );
      
      bool cacheGroup( const std::string& GroupName );
      bool purgeGroup( const std::string& GroupName );
      
      //Resoruce get functions
      c_Sprite*  createSprite( const std::string& SpriteName );
      bool       freeSprite( const std::string& SpriteName, c_Sprite* Sprite );
      c_Texture* getTexture( const std::string& TextureName );
         
   private:    
      
      void init( void );
      
      bool loadScript( const std::string& ScriptName, std::list<c_Resource*>& NewResources );

      c_Resource* createResource( XMLNode& ResourceNode );
      
      void deleteResources( void );
   
   private:
      //Unimplemented
      c_ResourceMgr( const c_ResourceMgr& );
      c_ResourceMgr operator=( const c_ResourceMgr& );

   private:

      std::multimap< std::string, c_Resource* > m_GroupMap; //Map Group Names to resource;
      
      std::map< std::string, c_Resource* > m_NameMap; //Map resoruce Names to resource;
      
      std::list<c_Resource*> m_Resources;
   };
   
};

#endif //WII_GI_C_RESOURCE_MGR_H
